import { Component, Vue, Model } from 'vue-property-decorator';


@Component({
    name: 'appMain',
})

export default class appMain extends Vue {
    private editableTabsValue: string = 'dashboard';
    private editableTabs: Array<any> = [{
        title: '面板',
        name: 'dashboard',
        content: '',
        closable: false
    }]

    removeTab(targetName: string) {
        let tabs = this.editableTabs;
        let activeName = this.editableTabsValue;
        if (activeName === targetName) {
            tabs.forEach((tab, index) => {
                if (tab.name === targetName) {
                    let nextTab = tabs[index + 1] || tabs[index - 1];
                    if (nextTab) {
                        activeName = nextTab.name;
                    }
                }
            });
        }

        this.editableTabsValue = activeName;
        this.editableTabs = tabs.filter(tab => tab.name !== targetName);
    }
}